<template></template>
<script>
  export default {
    name:'BaseVue',
    data(){
      return {

      }
    },
    methods:{
      // 开始递归遍历
      startRecursionTreeData(resource,props){
        return resource.map(k => {
          let obj = {
            label: k[props.label],
            value: k[props.value],
          }
          this.conversionTree(k, obj,props)
          return obj;
        })
      },

      // 组装级联选择器数据
      conversionTree(k, obj,props) {
        if (k.children && k.children.length > 0) {
           obj.children=[]
          k.children.forEach(v => {
            let childremObj = {
             label: v[props.label],
             value: v[props.value],
            }
            obj.children.push(childremObj)
            if (v.children && v.children.length > 0){
              childremObj.children= []
                this.conversionTree(v, childremObj,props)
            }
          })
        }
      }
    }
  }
</script>
